#include <stdio.h>

void main(){
	char s[10000];
	char c;
	scanf("%s",s);
	scanf(" %c",&c);
	char *p=s;
	int i=0;
	while (*p!=0){
		if (*p==c){
			i++;
		}
		p++;
	}
	printf("%d",i);
}
